package cool.lichuan.zabbix.request;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * @author LiChuan
 * @date 2021/11/4 9:21
 */
public class Request implements Serializable {
    private static final long serialVersionUID = 6988771362478806637L;
    /** API使用的JSON-RPC协议的版本; Zabbix API实现的JSON-RPC版本是2.0 */
    private String jsonrpc = "2.0";
    /** 被调用的API方法名 */
    private String method;
    /** 将被传递给API方法的参数 */
    private Map<String, Object> params = new HashMap<>(16);
    /** 请求的任意标识符 */
    private Integer id;
    /** 用户认证令牌; 如果没有的话可以设置为null */
    private String auth;

    public Request() {
    }

    public Request(String method, Integer id) {
        this.method = method;
        this.id = id;
    }

    public Request(String method, Map<String, Object> params, Integer id) {
        this.method = method;
        this.params = params;
        this.id = id;
    }

    public void putParam(String key, String value) {
        params.put(key, value);
    }

    public String getJsonrpc() {
        return jsonrpc;
    }

    public void setJsonrpc(String jsonrpc) {
        this.jsonrpc = jsonrpc;
    }

    public String getMethod() {
        return method;
    }

    public void setMethod(String method) {
        this.method = method;
    }

    public Map<String, Object> getParams() {
        return params;
    }

    public void setParams(Map<String, Object> params) {
        this.params = params;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getAuth() {
        return auth;
    }

    public void setAuth(String auth) {
        this.auth = auth;
    }

    @Override
    public String toString() {
        return "Request{" +
                "jsonrpc='" + jsonrpc + '\'' +
                ", method='" + method + '\'' +
                ", params=" + params +
                ", id='" + id + '\'' +
                ", auth='" + auth + '\'' +
                '}';
    }


}
